home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / dpkg.preinst < prev    next >
Encoding:
Text File  |  2007-03-06  |  4.5 KB  |  182 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Confirm that users are aware that conffile changes will be lost
  19. confirm_conffile_stomp() {
  20.     tempfile=/var/lib/dpkg/bp.$$
  21.  
  22.     trap 'status=$?; rm -f $tempfile; exit $status' 0
  23.     perl -000 -ne 'print $x if m/^Package:\s+(\S+\n)/im &&
  24.                                ($x=$1) ne "dpkg\n" &&
  25.                                m/^Status:.*(unpacked|postinst)/im' \
  26.         /var/lib/dpkg/status >$tempfile
  27.  
  28.     if [ -s $tempfile ]; then
  29.     echo "
  30. WARNING - have you read the release notes for this upgrade ?
  31.  
  32. The following packages have been unpacked but not yet configured:"
  33.     echo "  "`cat $tempfile`
  34.  
  35.     echo -n "
  36. If you proceed with the dpkg upgrade with these packages in this state
  37. you will LOSE ANY CONFIGURATION CHANGES that have been made to their
  38. configuration files.  I recommend that you back out of the upgrade
  39. now (see below) and then configure each of these packages using:
  40.   dpkg --configure --force-hold <package>
  41.  
  42. If you do this and it fails for some packages they are broken anyway, in
  43. which case you probably don't have that much to lose by going ahead
  44. with the upgrade.
  45.  
  46. Type \"yes\" to confirm that you really want to do the upgrade in
  47. spite of my warning above; if you give any other response we'll back
  48. off the upgrade to give you a chance to fix things.
  49.  
  50. Continue with upgrade despite probable loss of config data ? "
  51.  
  52.     read response
  53.     case "$response" in
  54.         [Yy][Ee][Ss])
  55.                 echo "OK, going ahead."
  56.         ;;
  57.         *)
  58.             echo "Aborting dpkg upgrade."
  59.         exit 1
  60.         ;;
  61.     esac
  62.     fi
  63.  
  64.     rm -f $tempfile
  65. }
  66.  
  67.  
  68. # Confirm that the user isn't upgrading anything else at the same time
  69. confirm_singleton() {
  70.     echo -n "
  71. IMPORTANT - you must install this upgrade on its own, not together in
  72. the same dpkg run as any other packages.  Otherwise you risk losing
  73. configuration information.
  74.  
  75. If you say \"no\" to the question below we'll back off the upgrade now,
  76. and you can then do it later using:
  77.   dpkg --install dpkg-0.93.51.deb
  78.  
  79. If you're not sure what to do, say \"no\", and then run that command
  80. (with the appropriate dpkg-*.deb filename) from a root shell prompt.
  81.  
  82. Are you installing only the dpkg upgrade in this dpkg run ? [y/n] "
  83.     read response
  84.     case "$response" in
  85.     [yY]*|"")
  86.             echo "OK, going ahead."
  87.         ;;
  88.     *)
  89.         echo "Aborting dpkg upgrade."
  90.         exit 1
  91.         ;;
  92.     esac
  93. }
  94.  
  95.  
  96. # Confirm that dselect got split into it's own package
  97. confirm_dselect_split() {
  98.     if [ -x /bin/ps ]; then
  99.     if ! ps -C dselect >/dev/null; then
  100.         return
  101.     fi
  102.     fi
  103.  
  104.     if ! grep "^Package: *dselect$" /var/lib/dpkg/status >/dev/null; then
  105.     echo -n "
  106. IMPORTANT - if you are upgrading this package from within dselect you
  107. _MUST_ install the dselect package first.
  108.  
  109. The dselect frontend has been split into a separate \`dselect' package,
  110. which has not yet been unpacked onto your system.  Continuing the upgrade
  111. will mean that dselect will temporarily be removed from your system, if
  112. this happens within dselect the upgrade will fail.
  113.  
  114. Type \"yes\" to confirm that you really want to do the upgrade in
  115. spite of my warning above (because you're not running dselect, for
  116. example); if you give any other response we'll back off the upgrade to
  117. give you a change to install the dselect package first.
  118.  
  119. Continue with upgrade despite separation of dselect ? "
  120.  
  121.     read response
  122.     case "$response" in
  123.         [Yy][Ee][Ss])
  124.                 echo "OK, going ahead."
  125.         ;;
  126.         *)
  127.             echo "Aborting dpkg upgrade."
  128.         exit 1
  129.         ;;
  130.     esac
  131.     fi
  132. }
  133.  
  134.  
  135. # Remove obsolete hd method scripts
  136. remove_hd_method() {
  137.     methoddir=/usr/lib/dpkg/methods/hd
  138.  
  139.     if [ -d $methoddir ]; then
  140.     echo "Removing obsolete $methoddir ..."
  141.     rm -r $methoddir
  142.     fi
  143. }
  144.  
  145.  
  146. case "$1" in
  147.     install)
  148.     ;;
  149.  
  150.     upgrade)
  151.     case "$2" in
  152.         # Upgrade from non-C dpkg (pre-0.93.50)
  153.         0.93.[01234]* | -)
  154.             echo ""
  155.         echo "Contemplating upgrade of dpkg from pre-0.93.50 version ..."
  156.  
  157.         confirm_conffile_stomp
  158.         confirm_singleton
  159.         confirm_dselect_split
  160.             remove_hd_method
  161.         ;;
  162.         
  163.         # Upgrade from pre-dselect split
  164.         0.93.[5678][0-9]* | 1.[023456789]* | 1.1.* | 1.10 | 1.10.[12] )
  165.             confirm_dselect_split
  166.         ;;
  167.     esac
  168.     ;;
  169.  
  170.     abort-upgrade)
  171.     ;;
  172.  
  173.  
  174.     *)
  175.     echo "$0 called with unknown argument \`$1'" 1>&2
  176.     exit 1
  177.     ;;
  178. esac
  179.  
  180.  
  181. exit 0
  182.